
<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url($data.module_url)}">{$data.module_name}列表</a>
                    </li>
                </ul>

            </div>

        </div>

        <!-- page content -->
        <div class="pagecontent">

            <!-- row -->
            <div class="row">
                <!-- col -->
                <div class="col-md-12">
                    <!-- tile -->
                    <section class="tile">
                        <form action="{:url($data.module_url)}" style="padding-top: 10px;" class="navbar-form form-inline" method="post">
                            <div class="form-group">
                                <label class="control-label" for="input-mobile">手机号码</label>
                                <div class="input-group">
                                    <input type="text" name="mobile" value="" placeholder="手机号码" id="input-mobile" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label" for="c_nickname">微信昵称</label>
                                <div class="input-group">
                                    <input type="text" name="c_nickname" value="" placeholder="微信昵称"  id="c_nickname" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">时间范围</label>
                                <div class="input-group">
                                    <input type="text" name="startTime" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px;padding: 16px;border: 1px solid #dbe0e2;" />至
                                    <input type="text" name="endTime" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px;padding: 16px;border: 1px solid #dbe0e2;" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">客戶状态</label>
                                <select name='customer_type' class="form-control">
                                    <option value='0'>全部</option>
                                    <option value='1'>新增</option>
                                    <option value='2'>潛在</option>
                                    <option value='3'>意向</option>
                                    <option value='4'>准客戶</option>
                                    <option value='5'>合作</option>
                                    <option value='6'>已认证</option>
                                    <option value='7'>已放弃</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-search"></i> 查詢</button>
                            </div>
                            <a href="{:url($data.module_url.'create')}" class="btn btn-info pull-right">新增客戶</a>
                        </form>

                        <div class="tile-body">
                           <div class="alert alert-info" style="display:none;">显示一些提示信息</div>

                            <div class="table-responsive">
                                <table class="table table-striped table-hover table-custom" id="products-list">
                                    <thead>
                                        <tr>
                                            <th>用户ID</th>
                                            <th>用户名</th>
                                            <th>微信昵称</th>
                                            <th>微信头像</th>
                                            <th>手机号</th>
                                            <th>性别</th>
                                            <th>会员等级</th>
                                            <th>客户状态</th>
                                            <th>添加时间</th>
                                            <th>操作 </th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        {foreach $list as $item}
                                        <tr id="tr_{$item['customers_id']}">
                                            <td style="vertical-align: middle" class="id">{$item['customers_id']}</td>
                                            <td style="vertical-align: middle" class="name">{$item['name']}</td>
                                            <td style="vertical-align: middle" class="nickname">{$item['c_nickname']}</td>
                                            <td style="vertical-align: middle" class="header_pic">
                                                <img src="{:gethead_pic($item['mobile'])}" width="40" height="40" style="border-radius: 50%;">
                                            </td>
                                            <td style="vertical-align: middle" class="mobile">{$item['mobile']}</td>
                                            <td style="vertical-align: middle" >
                                                {if condition="$item['sex'] eq 1"}男{elseif condition="$item['sex'] eq 2"}女{/if}
                                            </td>
                                            <td style="vertical-align: middle" >
                                                {if condition="$item['customer_levlel'] eq 1"}
                                                    铜牌
                                                {elseif condition="$item['customer_levlel'] eq 2"}
                                                    银牌
                                                {elseif condition="$item['customer_levlel'] eq 3"}
                                                    金牌
                                                {elseif condition="$item['customer_levlel'] eq 4"}
                                                    钻石
                                                {/if}
                                            </td>
                                            <td  style="vertical-align: middle;  position: relative;top: 10px;"
                                                 {if condition="$item['customer_type'] eq 1"}
                                                     <span class="btn">新增客户</span>
                                                {elseif condition="$item['customer_type'] eq 2"}
                                                     <span class="btn btn-info">潜在客户</span>
                                                {elseif condition="$item['customer_type'] eq 3"}
                                                     <span class="btn btn-success">意向客户</span>
                                                {elseif condition="$item['customer_type'] eq 4"}
                                                     <span class="btn btn-warning">准客户</span>
                                                {elseif condition="$item['customer_type'] eq 5"}
                                                     <span class="btn btn-primary"">合作客户</span>
                                                {elseif condition="$item['customer_type'] eq 6"}
                                                     <span class="btn btn-inverse">已认证</span>
                                                {else/}
                                                     <span class="btn btn-danger">已放弃</span>
                                                {/if}
                                            </td>
                                            <td  style="vertical-align: middle" >{$item['addtime']|date='Y-m-d H:i',###}</td>
                                            <td >
                                                <a class="btn btn-info owngoods" href="{:url($data.module_url.'owngoods',['mobile'=>$item['mobile']])}">
                                                    <i class="glyphicon glyphicon-user icon-white" ></i>
                                                    ta的拍品
                                                </a>
                                                <a class="btn btn-info addfollow"  customers_id="{$item['customers_id']}" href="javascript:void(0)">
                                                    <i class="glyphicon glyphicon-plus icon-white" ></i>
                                                    新增跟进
                                                </a>
                                                <a class="btn btn-info" id="followLog" href="{:url($data.module_url.'followloglist',['customers_id'=>$item['customers_id']])}">
                                                    <i class="glyphicon glyphicon-list-alt icon-white" ></i>
                                                    跟进记录
                                                </a>
                                                <a class="btn btn-info" href="{:url($data.module_url.'read',['customers_id'=>$item['customers_id']])}">
                                                    <i class="glyphicon glyphicon-edit icon-white"></i>
                                                    编辑
                                                </a>
                                                <a class="btn btn-danger" href="javascript:;"  onclick="if(confirm('确定要删除该客户吗')){ deleteData({$item['customers_id']})}">
                                                    <i class="glyphicon glyphicon-trash icon-white"></i>
                                                    删除
                                                </a>
                                            </td>

                                        </tr>
                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                            <div class="text-center">{$list->render()}</div>
                        </div>
                        <!-- /tile body -->

                    </section>
                    <!-- /tile -->

                </div>
                <!-- /col -->
            </div>
            <!-- /row -->

        </div>
        <!-- /page content -->
        <script type="text/javascript">

            $('.addfollow').click(function(){
                var customers_id = $(this).attr('customers_id');

                $('#customers_id').val(customers_id);
                $('#myModal').modal('show');
            })
            function deleteData(customers_id){
                $.ajax({
                    type:"get",
                    data: {'customers_id':customers_id},
                    url:"{:url($data.module_url.'delete')}",
                    success:function(data){
                        if(data.error == 0){
                            $('#tr_'+data.customers_id).remove();
                        }
                        $('.alert').html(data.msg).show();
                        setTimeout(function() {
                            $('.alert').hide();
                        }, 3000);
                    },
                    error:function(data){

                    }
                });
            }
            function checkform(){
                var follow_time = document.getElementById("follow_time").value;
                var remark = document.getElementById("remark").value;
                if(!follow_time){
                    alert("跟进时间不能为空");
                    return false;
                }
                if(!remark){
                    alert("备注不能为空");
                    return false;
                }
                document.getElementById("myform").submit();
            }
        </script>

    </div>

</section>
<!--/ CONTENT -->

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">新增跟进</h4>
            </div>
            <div class="modal-body">
                <form id="myform" action="{:url($data.module_url).'addfollow'}" method="post">
                    <input type="hidden" name="customers_id" id="customers_id" value="" />
                    <table class="table">
                        <tr>
                            <td style="vertical-align: middle;">
                                跟进方式：
                            </td>
                            <td style="vertical-align: middle;">
                                <select class="form-control" name="follow_style" style="width:300px">
                                    <option value="1">电话</option>
                                    <option value="2">短信</option>
                                    <option value="3">QQ</option>
                                    <option value="4">微信</option>
                                    <option value="5">其他</option>
                                </select>
                            </td>

                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">
                                此次跟进时间：
                            </td>
                            <td >
                                <input type="text" name="follow_time" id="follow_time" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:300px" />
                            </td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">
                                下次跟进时间：
                            </td>
                            <td>
                                <input type="text" name="next_follow_time" id="next_follow_time" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:300px"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">
                                跟进备注：
                            </td>
                            <td>
                                <textarea id="remark" name="remark" class="form-control" rows="15" cols="15" style="width:300px"></textarea>
                            </td>
                        </tr>
                    </table>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="checkform()">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>